//
//  LSAnalyzeRecentNestedCell.m
//  LookScore
//
//  Created by wr on 2018/3/22.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSAnalyzeRecentNestedCell.h"
#import "LSAnalysisModel.h"
@implementation LSAnalyzeRecentNestedCell{
    
    NSMutableArray * _labelArray;
    
}
+(LSAnalyzeRecentNestedCell *)AnalyzeRecentNestedCellByTableView:(UITableView *)tableView{
    LSAnalyzeRecentNestedCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSAnalyzeRecentNestedCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
    _labelArray = @[].mutableCopy;
    NSArray *titleArray = @[@"世界联赛17-09-10",@"莫斯科火车头 2-2 莫斯科火车头",@"0.5/1输"];
    CGFloat width=(LSScreenWidth - 30)/3;
    UILabel *lable;
    for (int i=0; i<3; i++) {
        lable=[UILabel new];
        lable.text = titleArray[i];
        lable.textColor = LSTitleGrayColor3;
        lable.font=LSFontSize(12, LSScreenWidth);
        lable.tag=i;
        [self.contentView addSubview:lable];
        
        [_labelArray addObject:lable];
        
        lable.sd_layout.leftEqualToView(self.contentView).offset(width*i + 10).topEqualToView(self.contentView).centerYEqualToView(self.contentView).widthIs(width).heightIs(30);
        if (i == 0) {
            lable.textAlignment = NSTextAlignmentLeft;
            lable.numberOfLines = 2;
            lable.sd_layout.widthIs(80);
        }
        else if (i == 1){
            lable.textAlignment = NSTextAlignmentCenter;
//            lable.sd_layout
//            .centerXEqualToView(self.contentView)
//            .centerYEqualToView(self.contentView)
//            .heightIs(30);
            [lable setSingleLineAutoResizeWithMaxWidth:200];
        }
        else{
            lable.textAlignment = NSTextAlignmentRight;
            lable.sd_layout.rightEqualToView(self.contentView).offset(-10).widthIs(80);
        }
    }
}


- (void)setModel:(teamArray *)model{
    _model = model;
    
    NSString * timeStr = [model.MatchTime componentsSeparatedByString:@" "].firstObject;
    NSArray * array = @[[NSString stringWithFormat:@"%@\n%@",model.LeagueName,timeStr],[NSString stringWithFormat:@"%@ %@ %@",model.HomeTeamName,model.QScore,model.GuestTeamName],[NSString stringWithFormat:@"%@%@",model.PanLu,model.Result]];
    
    [_labelArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel * label = (UILabel *)obj;
        label.text = array[idx];
    }];
    
    
    
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
